<template>
  <el-dialog :visible='visible' title="名称修改意见"
             @open="openDialog"
             @close="closeDialog">
    <el-row>
      <el-col :span="6">当前名称: </el-col>
      <el-col :span="17" v-html="crtName"></el-col>
    </el-row>
    <el-row style="height: 40px; " v-if="status === 0 || status === 3 || UTIL.isNotEmpty(nameSuggestionBak.editorNameSuggestion)">
      <el-col style="margin-top: 10px; " :span="6">
        <span>编辑人员名称修改意见</span>
      </el-col>
      <el-col :span="17">
        <!-- 未提交和初审驳回的任务, 编辑人员进入编辑页面 -->
        <KindEditor v-if="nameSuggestionBak.editorStatus === 0 && (status === 0 || status === 3)" :content.sync="nameSuggestionBak.editorNameSuggestion" editor-type="Input"/>
        <div style="margin-top: 10px; " v-else>
          <span v-html="nameSuggestionBak.editorNameSuggestion"/>
          <span v-html="' (' + CONST.NAME_SUGGESTION_STATUS[nameSuggestionBak.editorStatus] + ')'"/>
          <el-link type="primary" v-if="status === 0 || status === 3" @click="nameSuggestionBak.editorStatus = 0">重新编辑</el-link>
        </div>
      </el-col>
    </el-row>
    <el-row style="height: 40px; " v-if="status === 1 || status === 5 || UTIL.isNotEmpty(nameSuggestionBak.firstAuditorNameSuggestion)">
      <el-col style="margin-top: 10px; " :span="6">
        <span>初审人员名称修改意见</span>
      </el-col>
      <el-col :span="17">
        <!-- 初审中和复审驳回的任务, 初审人员进入编辑页面 -->
        <KindEditor v-if="nameSuggestionBak.firstAuditorStatus === 0 && (status === 1 || status === 5)" :content.sync="nameSuggestionBak.firstAuditorNameSuggestion" editor-type="Input"/>
        <div style="margin-top: 10px; " v-else>
          <span v-html="nameSuggestionBak.firstAuditorNameSuggestion"/>
          <span v-html="' (' + CONST.NAME_SUGGESTION_STATUS[nameSuggestionBak.firstAuditorStatus] + ')'"/>
          <el-link type="primary" v-if="status === 1 || status === 5" @click="nameSuggestionBak.firstAuditorStatus = 0">重新编辑</el-link>
        </div>
      </el-col>
    </el-row>
    <el-row style="height: 40px; " v-if="status === 4 || status === 7 || UTIL.isNotEmpty(nameSuggestionBak.secondAuditorNameSuggestion)">
      <el-col style="margin-top: 10px; " :span="6">
        <span>复审人员名称修改意见</span>
      </el-col>
      <el-col :span="17">
        <!-- 复审中和终审驳回的任务, 复审人员进入编辑页面 -->
        <KindEditor v-if="nameSuggestionBak.secondAuditorStatus === 0 && (status === 4 || status === 7)" :content.sync="nameSuggestionBak.secondAuditorNameSuggestion" editor-type="Input"/>
        <div style="margin-top: 10px; " v-else>
          <span v-html="nameSuggestionBak.secondAuditorNameSuggestion"/>
          <span v-html="' (' + CONST.NAME_SUGGESTION_STATUS[nameSuggestionBak.secondAuditorStatus] + ')'"/>
          <el-link type="primary" v-if="status === 4 || status === 7" @click="nameSuggestionBak.secondAuditorStatus = 0">重新编辑</el-link>
        </div>
      </el-col>
    </el-row>
    <el-row style="height: 40px; " v-if="status === 6 || status === 9 || UTIL.isNotEmpty(nameSuggestionBak.thirdAuditorNameSuggestion)">
      <el-col style="margin-top: 10px; " :span="6">
        <span>终审人员名称修改意见</span>
      </el-col>
      <el-col :span="17">
        <!-- 终审中的任务, 终审人员进入编辑页面 -->
        <KindEditor v-if="nameSuggestionBak.thirdAuditorStatus === 0 && (status === 6 || status === 9)" :content.sync="nameSuggestionBak.thirdAuditorNameSuggestion" editor-type="Input"/>
        <div style="margin-top: 10px; " v-else>
          <span v-html="nameSuggestionBak.thirdAuditorNameSuggestion"/>
          <span v-html="' (' + CONST.NAME_SUGGESTION_STATUS[nameSuggestionBak.thirdAuditorStatus] + ')'"/>
          <el-link type="primary" v-if="status === 6 || status === 9" @click="nameSuggestionBak.thirdAuditorStatus = 0">重新编辑</el-link>
        </div>
      </el-col>
    </el-row>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="cancel">取 消</el-button>
      <el-button size="small" type="primary" @click="confirm">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    name: "NameSuggestionDialog",
    props: ['nameSuggestion', 'auditLevel', 'status', 'visible', 'crtName'],
    data() {
      return {
        nameSuggestionBak: {},
        editFlag: false,
      }
    },
    methods: {
      openDialog() {
        if (this.nameSuggestion) {
          this.nameSuggestionBak = JSON.parse(JSON.stringify(this.nameSuggestion))
        }
      },
      closeDialog(){
        this.$emit('update:visible', false)
      },
      cancel(){
        this.$emit('cancel', false)
      },
      confirm(){
        this.$emit('confirm', this.nameSuggestionBak)
      }
    }
  }
</script>

<style scoped>

</style>
